package com.gitee.wsl.collections.trie

import com.gitee.wsl.collections.map.api.SortedMap
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
import kotlin.test.assertTrue


class PatriciaTrieTest {

    @Test
    fun testPatriciaTrie() {
        val trie = PatriciaTrie<Int>()
        trie.put("a", 1)
        trie.put("b", 2)
        trie.put("c", 3)
        trie.put("d", 4)
        trie.put("e", 5)
        trie.put("f", 6)
        trie.put("g", 7)
        trie.put("h", 8)
        trie.put("i", 9)

        trie.get("a")
    }

    @Test
    fun testPrefixMapClear() {
        val trie = PatriciaTrie<Int>()
        trie.put("Anna", 1)
        trie.put("Anael", 2)
        trie.put("Analu", 3)
        trie.put("Andreas", 4)
        trie.put("Andrea", 5)
        trie.put("Andres", 6)
        trie.put("Anatole", 7)
        val prefixMap = trie.prefixMap("And")
        assertContentEquals(HashSet(listOf("Andrea", "Andreas", "Andres")), prefixMap.keys.asIterable())
        assertContentEquals(listOf(5, 4, 6), ArrayList(prefixMap.values))

//        prefixMap.clear()
//        assertTrue(prefixMap.isEmpty())
//        assertTrue(prefixMap.isEmpty())
//        assertTrue(prefixMap.isEmpty())
//        assertContentEquals(HashSet(listOf("Anael", "Analu", "Anatole", "Anna")), trie.keys.asIterable())
//        assertContentEquals(listOf(2, 3, 7, 1), ArrayList(trie.values))
    }
}